

<div id='type2_area1'>
	<h2 style='text-align:center' ><span class='type2_area1_title'>征候</span>管理</h2>

	<div style='margin-bottom:20px'>
		<button id='main_type2_root_viewAdd'>添加<span class='type2_area1_title'>征候</span></button>
		<div id='main_type2_root_addArea' style='display:none'>
			<input type="text" id='main_type2_root_inp' />
			<button id='main_type2_root_addBtn'>提交</button>
			<button id='main_type2_root_addCancel'>取消</button>
		</div>
	</div>

	<div id='zhengHou_list'>
		<!--div>征候名</div>
		<div style='margin-left:20px;word-break:break-all'>
				sss，sss
				<div style='float:right;color:blue'>
					<span onclick='_type1_upMove()'>上移</span>　
					<span onclick='_type2_loadEditPage()'>编辑</span>
				</div>
		</div-->
	</div>
</div>


<div id='type2_area2' style='display:none;border:0px solid;'></div>


<script>

var zhengHouData;	//征候集合临时容器
var zhengHouItem;	//单条征候临时容器
var tmp_index;		//记录当前选择征候的下标


//显示标题
switch(sessionStorage.sel_val){
	case '2':case 2:
		var title = '征候';
	break;
	case '3':case 3:
		var title = '经方';
	break;
}
$('.type2_area1_title').text(title);


_zhengHou_init(); //初始化


//初始化
function _zhengHou_init(){
	_getZhengHouList(function(res){
		zhengHouData = res.data;
		if(res.data && res.data.length > 0){
			_parseData(res.data);
		}
	});
}

//解析征候数据 
function _parseData(data){
	var tmp_str = '';
	for(var i=0;i<data.length;i++){
		tmp_str += "<div style='margin:10px 0;font:normal bold 20px/25px normal'>"+data[i].name+"<span style='margin-left:35px;font-size:12px'>序号："+data[i].orders+"</span></div>";
		tmp_str += "<div style='margin-left:20px;word-break:break-all'>";
				if(data[i].subList && data[i].subList.length > 0){
					for(var j=0;j<data[i].subList.length;j++){
						tmp_str += "<span style='margin-right:20px'>"+data[i].subList[j].name+"，</span>";
					}
				}
				tmp_str += "<div style='float:right;color:blue'>";
					tmp_str += "<span onclick=_zhengHou_upDown("+data[i].id+",'up')>下移</span>　";
					tmp_str += "<span onclick=_zhengHou_upDown("+data[i].id+",'down')>上移</span>　";
					tmp_str += "<span onclick=_type2_loadEditPage("+i+")>编辑</span>";
				tmp_str += "</div><div style='clear:both'></div>";
		tmp_str += "</div>";
	}
	$('#zhengHou_list').html(tmp_str);
}


//加载征候编辑页
function _type2_loadEditPage(index){
	tmp_index = index;
	$('#type2_area1').hide();
	$('#type2_area2').show();
	Ajax({},function(res){
		$('#type2_area2').html(res);
	},'main_type2_edit.html')
}




//征候上移下移
function _zhengHou_upDown(id,ctype){
	var data = {
		type:'zhengHou_upDown',
		id:id,
		ctype:ctype
	}
	Notice2(1);
	Ajax2(data,function(res){
		Notice2();
		if(res.stat == 'ok'){
			//A('操作成功！');
			_zhengHou_init(); //初始化
		}else{
			A('操作失败！');
		}
	});
}










//添加症候相关
$("#main_type2_root_viewAdd").click(function(){
	$(this).hide();
	$('#main_type2_root_addArea').show();
});
$('#main_type2_root_addCancel').click(function(){
	_main_type2_root_addAreaInit();
});
$('#main_type2_root_addBtn').click(function(){
	var name = $('#main_type2_root_inp').val().trim();
	if(!name){
		return;
	}
	Notice2(1);
	var data = {
		type:'addZhengHou',
		name:name,
		ctype:sessionStorage.sel_val
	}
	Ajax2(data,function(res){
		Notice2();
		if(res.stat == 'ok'){
			A('添加成功！');
			//location.reload(1);
			_zhengHou_init(); //初始化
		}else{
			A('操作异常！');
		}
	})
	_main_type2_root_addAreaInit();
});

function _main_type2_root_addAreaInit(){
	$('#main_type2_root_viewAdd').show();
	$('#main_type2_root_addArea').hide();
	$('#main_type2_root_inp').val('');
}







</script>